import type {RouteRecordRaw} from 'vue-router'

const routes: RouteRecordRaw[] = [
    // 首页
    {
        path: '/',
        name: 'home',
        component: () => import('@/views/home/Home.vue'),
        meta: {
            title: '首页',
        }
    },

    // 认证相关路由
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/auth/Login.vue'),
        meta: {
            requiresGuest: true,
            title: '登录',
        }
    },
    {
        path: '/register',
        name: 'register',
        component: () => import('@/views/auth/Register.vue'),
        meta: {
            requiresGuest: true,
            title: '注册',
        }
    },
    {
        path: '/forgot-password',
        name: 'forgotPassword',
        component: () => import('@/views/auth/ForgotPassword.vue'),
        meta: {
            requiresGuest: true,
            title: '忘记密码',
        }
    },

    // 图片相关路由
    {
        path: '/picture',
        name: 'myPictures',
        component: () => import('@/views/picture/MyPictures.vue'),
        meta: {
            requiresAuth: true,
            title: '我的图片',
        }
    },
    {
        path: '/picture/upload',
        name: 'pictureUpload',
        component: () => import('@/views/picture/PictureUpload.vue'),
        meta: {
            requiresAuth: true,
            title: '上传图片',
        }
    },
    {
        path: '/picture/:id',
        name: 'pictureDetail',
        component: () => import('@/views/picture/PictureDetail.vue'),
        meta: {
            title: '图片详情',
        }
    },

    // 空间相关路由
    {
        path: '/space',
        name: 'spaceList',
        component: () => import('@/views/space/SpaceList.vue'),
        meta: {
            requiresAuth: true,
            title: '我的空间',
        }
    },
    {
        path: '/space/:id',
        name: 'spaceDetail',
        component: () => import('@/views/space/SpaceDetail.vue'),
        meta: {
            requiresAuth: true,
            title: '空间详情',
        }
    },

    // 用户相关路由
    {
        path: '/user/profile',
        name: 'userProfile',
        component: () => import('@/views/user/UserProfile.vue'),
        meta: {
            requiresAuth: true,
            title: '个人中心',
        }
    },

    // 探索页面
    {
        path: '/explore',
        name: 'explore',
        component: () => import('@/views/explore/Explore.vue'),
        meta: {
            title: '发现',
        }
    },

    // 管理员路由
    {
        path: '/admin',
        name: 'admin',
        component: () => import('@/views/admin/AdminLayout.vue'),
        redirect: '/admin/user',
        meta: {
            requiresAuth: true,
            requiresAdmin: true,
            title: '管理后台',
        },
        children: [
            {
                path: 'user',
                name: 'adminUser',
                component: () => import('@/views/admin/UserManagement.vue'),
                meta: {
                    requiresAuth: true,
                    requiresAdmin: true,
                    title: '用户管理',
                }
            },
            {
                path: 'picture',
                name: 'adminPicture',
                component: () => import('@/views/admin/PictureManagement.vue'),
                meta: {
                    requiresAuth: true,
                    requiresAdmin: true,
                    title: '图片审核',
                }
            },
        ]
    },

    // 404页面
    {
        path: '/:pathMatch(.*)*',
        name: 'notFound',
        component: () => import('@/views/common/NotFound.vue'),
        meta: {
            title: '页面未找到',
        }
    },
]

export default routes

